<template>
	<view class="container">
		<view class="head" v-if="userInfo.agent_info">
			<view class="left">
				<image :src="userInfo.avatar" mode=""></image>
			</view>
			<view class="right">
				<text class="name">{{userInfo.nickname}}</text>
				<text class="recomment" v-if="isRecommend">推荐人：{{userInfo.agent_info[0]}}</text>
				<text class="level">{{this.agentInfo.type==1?this.agentInfo.province:this.agentInfo.type==2?(this.agentInfo.province+this.agentInfo.city):(this.agentInfo.province+this.agentInfo.city+this.agentInfo.area)}} 代理</text>
			</view>
		</view>
		<view class="content">
			<view class="list" @tap="dump(0)">
				<image src="../../static/icon/leijifenghong.png" mode=""></image>
				<text>累计分红</text>
				<text>{{agentReward.total}}</text>
			</view>
			<view class="list" @tap="dump(1)">
				<image src="../../static/icon/daijiesuanfenhong.png" mode=""></image>
				<text>待结算分红</text>
				<text>{{agentReward.w_total}}</text>
			</view>
			<view class="list" @tap="dump(2)">
				<image src="../../static/icon/yijiesuanfenhong.png" mode=""></image>
				<text>已结算分红</text>
				<text>{{agentReward.y_total}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import service from '@/store/service.js';
	export default {
		data() {
			return {
				page:1,
				limit:10,
				userInfo:{},
				isRecommend:true,
				agentReward:{},
				agentInfo:{}
			};
		},
		methods:{
			// 代理分红统计
			getAgentReward(){
				this.$http.post(service.api.profile.getAgentReward).then(res=>{
					console.log(res,'getAgentReward');
					if(res.code === 1){
						this.agentReward = res.data
					}else{
						this.$api.msg(res.info)
					}
				})
			},
			// 获取用户信息
			getInfo(){
				this.$http.post(service.api.profile.getInfo).then(res=>{
					console.log(res);
					if(res.code === 1){
						this.userInfo = res.data
						this.userInfo.agent_info.length>0?(this.isRecommend=true):(this.isRecommend=false)
					}else{
						this.$api.msg(res.info)
					}
				})
			},
			dump(params){
				uni.navigateTo({
					// url:'./shareBonusList/shareBonusList?type='+params
					url:'./bonusList?type='+params
				})
			},
			getApplyInfo(){
				 this.$http.post(service.api.profile.getApplyInfo).then(res=>{
					if(res.code===1){
						this.agentInfo = res.data
						console.log(this.agentInfo,'infofff');
					}
				})
			}
		},
		onLoad() {
			this.getInfo()
			this.getAgentReward()
			this.getApplyInfo()
		}
	}
</script>

<style lang="less">
	.container{
		height: 100%;
		width: 100%;
		.head{
			height: 180rpx;
			width: 100%;
			background-color: #F8124A;
			padding: 0 20rpx;
			display: flex;
			align-items: center;
			.left{
				height: 120rpx;
				width: 120rpx;
				border-radius: 50%;
				>image{
					height: 100%;
					width: 100%;
				}
			}
			.right{
				margin-left: 30rpx;
				display: flex;
				flex-direction: column;
				font-size: 26rpx;
				font-weight: 600;
				color: #FFFFFF;
				padding: 20rpx 0;
				line-height: 50rpx;
				.level{
					min-width: 150rpx;
					max-width: 250rpx;
					text-align: center;
					padding: 5rpx;
					white-space: nowrap;
					font-size: 28rpx;
				}
			}
		}
		.content{
			margin-top: 20rpx;
			height: 100%;
			width: 100%;
			background-color: #FFFFFF;
			display: flex;
			flex-wrap: wrap;
			.list{
				height: 200rpx;
				width: 33.333%;
				border: 1px solid #EEEEEE;
				box-sizing: border-box;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				>image{
					height: 80rpx;
					width: 80rpx;
				}
				& text:first-child{
					font-size: 26px;
					font-weight: 500;
				}
				& text:last-child{
					color: #F8124A;
					font-size: 26rpx;
					font-weight: 600;
				}
			}
		}
	}
</style>
